/**
  \mainpage
  ETFRoot project, Anyang Normal University && IMP-CAS
  \brief unpack binary data from daq. Note that this is a root macro that can be
  interpreted directed by root, without compilation. For compiled run, please
  use unpack.cxx that wraps in unpack.C
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-10-06
  \date 2021-10-06 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-10-06   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

void unpackVME(){
  setenv("VMCWORKDIR", TString(get_current_dir_name())+"/../ETFAna", true);

  ETFVMEOfflineSource *source = new ETFVMEOfflineSource("../20180708.003");
  FairRunOnline *run = new FairRunOnline(source);
  source->AddUnpacker(new ETFUserVMEUnpacker());
  run->SetSink(new FairRootFileSink(source->ROOTFileName()));
  run->AddTask(new ETFUserUnpackTask()); // add analysis task
  run->Init();

  TStopwatch timer;
  // prepare and read the events
  timer.Start();
  run->Run(-1, 3000); // (ev_start, ev_stop): set ev_start<0 to run all the events
  timer.Stop();

  cout << endl << "Real time: " << timer.RealTime() << "s" << endl;
  cout << "CPU time: " << timer.CpuTime() << "s." << endl;
} // end the main function sim
